
#ifndef __LIBERTY_ENGINE_UUID_H__
#define __LIBERTY_ENGINE_UUID_H__

#include <Liberty3D/Liberty3D.h>

#include <functional>
#include <string>

namespace Liberty { namespace Engine {
    
    class Uuid {
    protected:
        unsigned int data[4];
        
    public:
        inline Uuid() {
            data[0] = data[1] = data[2] = data[3] = 0;
        }
        
        Uuid(const std::string& uuid);
        Uuid(const char* uuid);
        
    public:
        inline bool operator == (const Uuid& uuid) const {
            return
                data[0] == uuid.data[0] &&
                data[1] == uuid.data[1] &&
                data[2] == uuid.data[2] &&
                data[3] == uuid.data[3];
        }

        inline bool operator != (const Uuid& uuid) const {
            return !((*this) == uuid);
        }

        inline bool isNull() const {
            return
                data[0] == 0 &&
                data[1] == 0 &&
                data[2] == 0 &&
                data[3] == 0;
        }

    public:
        static Uuid create();
        
        std::string toString() const;
        
    public:
        inline unsigned int operator[](int index) const {
            return data[index];
        }
        
    public:
        size_t hash() const;
    };
}}

namespace std {
    template <> struct hash<Liberty::Engine::Uuid> {
        size_t operator()(const Liberty::Engine::Uuid& uuid) const {
            return uuid.hash();
        }
    };
}

#endif
